package barinadroid.game;

import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.DelayModifier;
import org.andengine.entity.modifier.IEntityModifier.IEntityModifierListener;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.util.modifier.IModifier;
import android.util.Log;

public class LoadingScene extends Scene
{
	public static LoadingScene instance;

	public static LoadingScene getSharedInstance()
	{
		if(instance == null)
			instance = new LoadingScene();
		return instance;
	}

	GameActivity gameActivity;

	private LoadingScene()
	{
		setBackground(new Background(0, 0.7f, 0));
		gameActivity = (GameActivity)GameActivity.getSharedInstance();
		loadResources();
	}

	public void loadResources()
	{
		DelayModifier dMod = new DelayModifier(2, new IEntityModifierListener()
		{
			@Override
			public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem)
			{}

			@Override
			public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem)
			{
				gameActivity.setCurrentScene(MainMenuScene.getSharedInstance());
				Log.i("LoadingScene", "modifier did finish and mainmenuscene is '" + MainMenuScene.getSharedInstance());
			}
		});
		registerEntityModifier(dMod);
	}
}